package com.lambada;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Zhang Zhe
 * @since 2020年02月25日 22:27:00
 */
public class Test {

	public static void main(String[] args) {
		ArrayList<User> users = new ArrayList<>();
		users.add(new User(1));
		users.add(new User(2));
		users.add(new User(3));
		users.add(new User(4));
		testMap(users);
	}

	public static void  testMap(ArrayList<User> users){
		List<Integer> collect = users.stream().map(User::getA).collect(Collectors.toList());
		users.stream().forEach(user -> {
			System.out.println(user.getA());
		});

	}

	public static void testForeach(List<User> users){
		users.stream().forEach(user -> {
			user.setA(10);
		});

		User user1 = new User(1);
		User user2 = user1;
		user2.setA(2);
		System.out.println(user1.getA());
	}

}

class User{

	public User(Integer a) {
		this.a = a;
	}

	Integer a ;

	public Integer getA() {
		return a;
	}

	public void setA(Integer a) {
		this.a = a;
	}
}